<?php
//by willson 105328468@qq.com 2014/10/11
//index page interface

class commission extends core {

	public function __construct() {
		parent::__construct();
	}

	//列表
	public function index() {
		$where = '';
		$status = (isset($_GET['status'])) ? trim($_GET['status']) : '';
		$keyword = (isset($_GET['keyword']) && trim($_GET['keyword'])) ? trim($_GET['keyword']) : '';
		if ($keyword) {
			$where .= "AND (m.name LIKE '%{$keyword}%' OR m.mobile LIKE '%{$keyword}%' OR c.memo LIKE '%{$keyword}%')";
		}
		if (strlen($status)) {
			$where .= "AND c.status='{$status}'";
		}
		//分页
		$this->setpages(array('keyword'=>$keyword,  'status'=>$status));
		$sql = "SELECT c.*, m.name, m.mobile ,m.invite_code
			FROM {$this->tbp}member_commission c LEFT JOIN {$this->tbp}member m ON c.member_id=m.id
			WHERE c.commission>0 {$where}
			ORDER BY c.id DESC";
		//echo $sql;
		$rs = $this->ezr->get_results($sql);
		$nav = $this->ezr->get_navigation();
		$this->smarty->assign('rs',$rs);
		$this->smarty->assign('keyword',$keyword);
		$this->smarty->assign('status',$status);
		$this->smarty->assign('page',$nav);
		$this->display();
	}
}
